//
//  FKFastShareVC.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/13.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKFastShareVC.h"
#import <JXCategoryView.h>
#import "FKFastShareChildVC.h"

@interface FKFastShareVC ()<JXCategoryViewDelegate>

//@property (nonatomic, weak) JXCategoryTitleView *categoryView;

@end

@implementation FKFastShareVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSArray * titles = @[@"商品推荐", @"营销素材"];
    
    // 默认为user类型
    CGFloat headerH = 44;
    JXCategoryTitleView *categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, fkScreenW, headerH)];
    [self.view addSubview:categoryView];
    
    UIView *separator = [UIView fk_lineWithFrame:CGRectMake(0, headerH - 0.8, fkScreenW, 0.8)];
    [self.view addSubview:separator];
    
    UIScrollView *scrollView = [[UIScrollView alloc] init];
    [self.view addSubview:scrollView];
    scrollView.pagingEnabled = true;
    scrollView.showsHorizontalScrollIndicator = false;
    scrollView.bounces = false;
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(separator.mas_bottom);
        make.left.bottom.right.offset(0);
    }];
    
//    self.categoryView = categoryView;
    categoryView.titleSelectedColor = fkMainColor;
    categoryView.delegate = self;
    categoryView.titleColorGradientEnabled = YES;
    categoryView.titles = titles;
    categoryView.backgroundColor = [UIColor whiteColor];
    
    JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
    categoryView.indicators = @[lineView];
    lineView.indicatorLineViewColor = fkMainColor;
    
    categoryView.contentScrollView = scrollView;
    scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag | UIScrollViewKeyboardDismissModeInteractive;
    
    CGFloat scrollH = fkScreenH - fkStatusAndNaBarH - headerH - fkTabBarH;
    
    for (NSInteger index = 0; index < titles.count; index++) {
        FKFastShareChildVC *vc = [[FKFastShareChildVC alloc] init];
        [self addChildViewController:vc];
        vc.type = index + 1;
        vc.tableView.frame = CGRectMake(index * fkScreenW, 0, fkScreenW, scrollH);
        [scrollView addSubview:vc.view];
    }
    
    scrollView.contentSize = CGSizeMake(fkScreenW * titles.count, 0);
}



@end
